<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *订单管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['status']=$this->order_status;
$tabs=array(
	array('op'=>'list','title'=>'全部记录'),
); 
$return['paytype']=get_pay_types();
if($_RQ['op']=='list'){
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(isset($_RQ['type'])){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=intval($_RQ['type']);
	}
	if($_RQ['mid']){
		$params['mid']=$_RQ['mid'];
		$return['params']['mid']=$_RQ['mid'];
	}
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['psize']){
		$_SESSION['psize']=$_RQ['psize'];
	}
	$psize = $_SESSION['psize']?:10;
	$list=pdo_getslice('jy_feejipiao_order',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as $k=>&$item){
			$item['member']=cfc('core')->member_show($item['mid']);
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','tip'=>'[温馨提示]：</br>这里显示所有的记录信息！','edit'=>false,'del_one'=>false,'delall'=>false,
		'total'=>$total,
		'psize'=>$psize,
		'list'=>array(
			array('name'=>'mid','title'=>'会员Mid','type'=>'string'),
			array('name'=>'member','title'=>'会员信息_Member','type'=>'member'),
			array('name'=>'start_city','title'=>'出发地','type'=>'string'),
			array('name'=>'end_city','title'=>'目的地','type'=>'string'),
			array('name'=>'name','title'=>'姓名','type'=>'string'),
			array('name'=>'mobile','title'=>'电话','type'=>'string'),
			array('name'=>'day','title'=>'日期','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'post','op'=>'status1','title'=>'审核订单','show'=>array('status'=>0)),
			array('type'=>'post','op'=>'status2','title'=>'确认已购票','show'=>array('status'=>1)),	
			array('type'=>'modal','op'=>'look','title'=>'查看信息'),
		)),
		'search'=>array(
			array('name'=>'status','width'=>15,'title'=>'状态','type'=>'radio','options'=>'status'),
			array('type'=>'choose','width'=>15,'action'=>'core/member.get_member/','name'=>'mid','title'=>'选择会员'),

		)
	);
	$return['htmls']=$htmls;	
	exi($return);
}
if($_RQ['op']=='look'){
	$id=intval($_RQ['id']);
	$item=$this->pdo_get('order',array('id'=>$id));	
	$item['member']=cfc('core')->member_show($item['mid']);
	$htmls=array(
		'type'=>'look',
		'desc'=>'查看信息',
	);
	$htmls['look']=array(
			array('name'=>'mid','title'=>'会员Mid','type'=>'string'),
			array('name'=>'member','title'=>'会员信息_Member','type'=>'member'),
			array('name'=>'start_city','title'=>'出发地','type'=>'string'),
			array('name'=>'end_city','title'=>'目的地','type'=>'string'),
			array('name'=>'name','title'=>'姓名','type'=>'string'),
			array('name'=>'mobile','title'=>'电话','type'=>'string'),
			array('name'=>'code','title'=>'身份证','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'time'),
	);
	$return['htmls']=$htmls;
	$return['item']=$item;
	exi($return);
}
if($_RQ['op']=='status1'){
	$id=intval($_RQ['id']);
	pdo_update('jy_feejipiao_order',array('status'=>1),array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	exi('操作成功！');
}
if($_RQ['op']=='status2'){
	$id=intval($_RQ['id']);
	pdo_update('jy_feejipiao_order',array('status'=>2),array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	exi('操作成功！');
}